class Solution:
    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        求最长不重复字符串，leetcode-003
        """
        i, tmp, longs = 0, [], 0
        while i < len(s):
            if s[i] not in tmp:
                tmp.append(s[i])
                i = i+1
                if len(tmp) >= longs:
                    longs = len(tmp)
            else:
                tmp = tmp[(tmp.index(s[i])+1):len(tmp)]
        return longs



sol = Solution()
s = "accaabcbb"
s2 = "dvdf"
s1 = "vwxyzABCD"
res = sol.lengthOfLongestSubstring(s1)
print(res)
